﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace @delegate
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //khai bao mot doi tuong la the hien cua 
            testdelegate ht = new testdelegate(tetst);
            // tien hanh goi ham la the hien cua delegate do
           string chuoikq= ht("sdsds", "sdsdsd");
           ht.Invoke("sdsds", "sdsdsds");// goi ham nhu coi no la mot doi tuong
          // MessageBox.Show(chuoikq);
           testtetst hst = new testtetst(kie);
           // Thread threa=new Thread(new ThreadStart(hst));
           // threa.Start();
        }
        public delegate string testdelegate(string chuoi1,string chuoi2);
        public delegate void testtetst();
        public string tetst(string chuoi1,string chuoi2)
        {
            return chuoi1+chuoi2;
        }
        public void kie()
        {
            
            
            
            
            
            button2.Text = "";
        }
    }
}
